package com.dwxt.parabolic.service;

import org.springframework.stereotype.Service;

import java.io.File;

@Service
public class TaskService {

    public void deleteFile() {
        // System.out.println(Thread.currentThread().getName());
        String path = "/app/city/img/upload/event/zip/";
        File file = new File(path);
        deleteDir(file);
    }

    public static void deleteDir(File file) {
        //判断是否为文件夹
        if (file.isDirectory()) {
            //获取该文件夹下的子文件夹
            File[] files = file.listFiles();
            //循环子文件夹重复调用delete方法
            for (int i = 0; i < files.length; i++) {
                deleteDir(files[i]);
            }
        }else {
            //若为空文件夹或者文件删除，File类的删除方法
            file.delete();
        }
    }

}
